package ru.mytnik.supergym.core;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;

/**
 * Парсит расписание из html
 * @author Anton Mytnik <MytnikAA@gmail.com>
 */
public class ScheduleParser {
    private String html;
    private String scheduleHtmlTable;

    public ScheduleParser(String html) {
        this.html = html;
    }

    public String getHtml() {
        return html;
    }

    public void setHtml(String html) {
        this.html = html;
    }
    
    public Schedule parse() {
        Document page = Jsoup.parse(html);
        Elements tables = page.getElementsByTag("table");
        Elements h2s = page.getElementsByTag("h2");
        scheduleHtmlTable = tables.get(0).toString();
        String month = h2s.get(0).text();
        return new Schedule(scheduleHtmlTable, month);
    }
    
}
